/*
 * $Id: Log.java,v 1.4 2004/10/06 20:03:05 jppietsch Exp $
 * Copyright (C) 2001 Jan-Peter Pietsch
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package de.jppietsch.error;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * A convenient Logger, helpful to avoid stupid typing.
 *
 * @author Jan-Peter Pietsch
 * @version $Revision: 1.4 $
 */
public final class Log extends Logger {

    // constants

    public static final Log LOG = new Log();

    // constructors

    private Log() {
        super("de.jppietsch", "de.jppietsch.error.Rsc");

        setLevel(Level.ALL);
    }

    // public methods

    public static void caught(Throwable aThrowable) {
        LOG.log(Level.SEVERE, "", aThrowable);
    }

    /**
     * Convenience method to issue an "index out of bounds" warning.
     *
     * @param anObject Whose class is used for the warning. (It's more convenient
     *                 than giving the class, because the caller doesn't have to
     *                 extract the class.)
     * @param aMethod  Name of the method.
     * @param aName    Name of the parameter, field or local variable, which is out
     *                 of bounds.
     * @param aValue   Actual value of <code>aName</code>.
     */
    public static void indexOutOfBounds(Object anObject, String aMethod,
                                        String aName, long aValue) {
        LOG.logp(Level.WARNING, anObject.getClass().getName(), aMethod,
                Rsc.INDEX_OUT_OF_BOUNDS_MSG, new Object[]{aName,
                new Long(aValue)});
    }

}